<template>
	<view class="index" v-if="pageLoad">
		<view class="uni-list">
			<view class="uni-list-cell" hover-class="uni-list-cell-hover" v-for="(item,key) in showTypes" :key="key"  @click="goTo(item)">
				<view class="uni-list-cell-navigate uni-navigate-right uni-media-list ">
					<image class="uni-media-list-logo" :src="item.imgUrl"></image>
					<view class="uni-media-list-body" >
						{{item.text}}
					</view>
				</view>
			</view>
		</view>
		
		<view class="uni-list">
			<view class="uni-list-cell" hover-class="uni-list-cell-hover" v-for="(item,key2) in ranks" :key="key2" @click="goTo(item)">
				<view class="uni-list-cell-navigate uni-navigate-right uni-media-list ">

					<image class="uni-media-list-logo" :src="item.imgUrl"></image>
					<view class="uni-media-list-body" >
						{{item.text}}
					</view>
				</view>
			</view>
		</view>
		<view class="uni-list">
			<view class="uni-list-cell" hover-class="uni-list-cell-hover" v-for="(item,key3) in plays" :key="key3" @click="goTo(item)">
				<view class="uni-list-cell-navigate uni-navigate-right uni-media-list ">
					<image class="uni-media-list-logo" :src="item.imgUrl"></image>
					<view class="uni-media-list-body" >
						{{item.text}}
					</view>
				</view>
			</view>
		</view>
		<view class="uni-list">
			<view class="uni-list-cell" hover-class="uni-list-cell-hover" v-for="(item,key4) in others" :key="key4" @click="goTo(item)">
				<view class="uni-list-cell-navigate uni-navigate-right uni-media-list ">

					<image class="uni-media-list-logo" :src="item.imgUrl"></image>
					<view class="uni-media-list-body" >
						{{item.text}}
					</view>
				</view>
			</view>
		</view>
	
	</view>
	
</template>

<script>
	import {All} from '@/api/cms/category';


	export default {
		data() {
			return {
				titleText: "发现",
				statusColor: "#7C4BF9",
				showLeftButton: false,
				pageLoad: false,
				showTypes: [
					
				],
				ranks:[
					{
						text:'魅力榜单',	
						imgUrl: '../../../static/image/found/charm.png',
						navigatePage: '/pages/cms/rank',
						navigateValue: 0
					},
					{
						text:'贡献榜单',	
						imgUrl: '../../../static/image/found/contribute.png',
						navigatePage: '/pages/cms/rank',
						navigateValue: 1
					},
				],
				plays: [
					// #ifdef APP-PLUS
					{
						text:'来一发',	
						imgUrl: '../../../static/image/found/vertical.png',
						navigatePage: '/platforms/app-plus/shake/pose',
						navigateValue: 0
					},
					// #endif
					{
						text:'每日签到',	
						imgUrl: '../../../static/image/found/signature.png',
						navigatePage: '/pages/cms/sign',
						navigateValue: 0
					}
				],
				others: [
					{
						text:'积分规则',	
						imgUrl: '../../../static/image/found/jifen.png',
						navigatePage: '/pages/mall/rule',
						navigateValue: 0
					},
					{
						text:'安全购物',	
						imgUrl: '../../../static/image/found/security.png',
						navigatePage: '/pages/cms/buy',
						navigateValue: 0
					},
					{
						text:'玩转社区',	
						imgUrl: '../../../static/image/found/play.png',
						navigatePage: '/pages/cms/play',
						navigateValue: 0
					}
				],
			}
		},
		onLoad: function () {
			this.loadShowTypes();
			
		},
		onShareAppMessage() {
			console.log("点击了自定义按钮");
		},
		onNavigationBarButtonTap: function(e) {
			console.log(e.index);
			if(e.index == 0) {
				uni.navigateTo({
					url: "/pages/im/conversation"
				})
			} else if(e.index == 1) {
				uni.navigateTo({
					url: "/pages/cms/push"
				})
			}
		},
		onUnload:function(){
		},
		methods: {
			loadShowTypes: function(){
				var that = this;
				All().then(function(res){

					for(var i =0; i < res.length; i++){
//						console.log(JSON.stringify(res[i]))
						
						that.showTypes.push({
							
							 
							text: res[i].typeName,
							imgUrl: '../../../static/image/found/'+res[i].showTypeId+'.png',
							navigateValue: res[i].showTypeId,
							navigatePage: '/pages/cms/module'
							
	
						});
						
// 						// #ifdef APP-PLUS 
// 						that.showTypes.push({text: res[i].typeName,
// 						imgUrl: '../../../static/image/found/'+res[i].showTypeId+'.png',
// 						navigateValue: res[i].showTypeId,
// 						navigatePage: '/pages/cms/nmodule'});
// 						// #endif
						
						that.pageLoad = true;
					}
					
				});
			},
			goTo: function(e){
				if(e.navigatePage.indexOf("/n") > 0)
				{
					uni.setStorageSync("$tempCategoryId", e.navigateValue);
				}
				uni.navigateTo({
					url: e.navigatePage+"?navigateValue=" + e.navigateValue
				})
				console.log(e.navigatePage.indexOf("n"));
			}
		}
	}
</script>

<style>
	
	
	.index {
		display: flex;
		flex: 1;
		flex-direction: column;
		overflow: hidden;
		height: 100%;
		width: 750upx;
	}

	.uni-list {
		width: 710upx !important;
		margin: 20upx;
		border-radius: 15upx;
	}
	
	.uni-media-list-logo {
		width: 50upx;
		height: 50upx;
	}

	.uni-media-list-body {
		width: 50upx;
		height: 50upx;
		font-size: 28upx;
	}
	
	/* .uni-media-list-text-bottom {
		display: flex;
		flex-direction: row;
		justify-content: space-between;
	} */
</style>
